<?php

class Dao_Static_Harbor extends Dao_Static_Abstract
{
    protected $_dbName     = 'voyage_share';
    protected $_tableName  = 'harbor';
    protected $_primaryKey = 'harbor_id';
    protected $_nameField  = 'harbor_name';

    const DEFAULT_DIST_TIME = 60;

    public function getFull($harborId)
    {
        $harborRow = $this->get($harborId);
        if ($harborRow) {
            $harborRow['sea_area'] = Dao('Static_SeaArea')->get($harborRow['sea_area_id']);
        }

        return $harborRow;
    }

    public function getDistance($harborFrom, $harborTo)
    {
        $distanceTime = $this->_db()->fetchOne("SELECT `distance_time` FROM `harbor_distance` WHERE `harbor_from` = '{$harborFrom}' AND `harbor_to` = '{$harborTo}'");
        return $distanceTime ? $distanceTime : self::DEFAULT_DIST_TIME;
    }
}